package project.adapter;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import approve.action.R;
import project.active.Projectdetail_listerror_tc;
import project.model.*;

public class Projectdetail_listerror_adapter_tc extends BaseAdapter implements OnClickListener {

	private Context context;
	private List<PrTestProject> listError;
	
	public Projectdetail_listerror_adapter_tc(Context context,List<PrTestProject> listError){
		this.context=context;
		this.listError=listError;
	}
	public int getCount() {
		// TODO Auto-generated method stub
		return listError.size();
	}
	

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return listError.get(position);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		PrTestProject entry=listError.get(position);
		if(convertView==null){
			LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView=inflater.inflate(R.layout.listerror_row, null);
		}
		TextView tvTitleError=(TextView)convertView.findViewById(R.id.titleError);
		String title=entry.getTitleview();
		Spannable WordtoSpan = new SpannableString(title);        
		WordtoSpan.setSpan(new ForegroundColorSpan(Color.parseColor(entry.getColorText())), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
		tvTitleError.setText(WordtoSpan);
		TextView tvPhone = (TextView) convertView.findViewById(R.id.tvMobile);
        tvPhone.setText(entry.getEmployeeName()+"-"+entry.getTime());
		return convertView;
	}

	public void onClick(View v) {
		// TODO Auto-generated method stub
		
	}

}
